#include <iostream>
using namespace std;


long long find(long long x,long long *f){
	if(f[x] == x) return x;
	return f[x]=find(f[x],f);
}


int main(){
	long long n,m,now;
	long long tf=-1;
	cin>>n>>m;
	n--;
	now = (n*n+n)/2;
	n++;
	long long f[n],num[n],ans[m];
	ans[m-1] = now;
	long long node[2][m];
	for(int i=0;i<n;i++){
		num[i] = 1;
		f[i] = i;
	}
	for(int i=0;i<m;i++)
		cin>>node[0][i]>>node[1][i];
	for(int i=m-1;i>0;i--){
		long long s,t;
		s = node[0][i]-1;
		t = node[1][i]-1;
		long long f1,f2;
		f1 = find(s,f);
		f2 = find(t,f);
		if(f1 == f2){
			if(num[f1] == n){
				tf = i-1;
				break;
			}
			else{
				ans[i-1] = now;
				continue;
			}
		}
		now -= num[f1]*num[f2];
		if(now < 0)
			now = 0;
		ans[i-1] = now;
		f[f2] = f[f1];
		num[f1] += num[f2];
	}
	for(int i=0;i<m;i++){
		if(tf != -1){
			if(i <= tf){
				cout<<0<<endl;
			}
			else{
				tf = -1;
				cout<<ans[i]<<endl;
			}
		}
		else{
			cout<<ans[i]<<endl;
		}
	}
	return 0;
}
